#include "Life.h"

const char* Life::FULLHEART_SPRITE_PATH = "media/sprites/fullheart.png";
const char* Life::EMPTYHEART_SPRITE_PATH = "media/sprites/emptyheart.png";

Life::Life(int vidaInicial, int xInicial,int yInicial)
{
    GuiSprite* fullHeart = new GuiSprite();
    GuiSprite* emptyHeart = new GuiSprite();

    for(int i=0;i<vidaInicial;i++)
    {
        fullHearts.push_front(*fullHeart);
        emptyHearts.push_front(*emptyHeart);

        fullHeart = new GuiSprite();
        emptyHeart = new GuiSprite();
    }
    init();
}

void Life::init()
{
    int i = 0;
    for (list<GuiSprite>::iterator spriteIt = emptyHearts.begin();spriteIt != emptyHearts.end();spriteIt++)
    {
        spriteIt->loadWithAlpha(Life::EMPTYHEART_SPRITE_PATH);
        spriteIt->scale(0.1,0.1);
        spriteIt->position(20 + 40*i, 20);
        i++;
    }

    i = 0;

    for (list<GuiSprite>::iterator spriteIt = fullHearts.begin();spriteIt != fullHearts.end();spriteIt++)
    {
        spriteIt->loadWithAlpha(Life::FULLHEART_SPRITE_PATH);
        spriteIt->scale(0.1,0.1);
        spriteIt->position(20 + 40*i, 20);
        i++;
    }
}
